﻿Imports Cognex.VisionPro

Public Class FormVision

    Private Sub FormVision_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim tmpPmalign1 As CogPMAlignTool = gTBCheck(0).Tools.Item("CogPMAlignTool1")
        CogPMAlignEditV21.Subject = tmpPmalign1
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Try
            Dim i As Integer
            Dim path As String = DebugPath & "\Tool\" & Chanpin & "\"
            If Dir(path, FileAttribute.Directory) = "" Then '如果路径不存在,则创建路径
                MkDir(path)
            End If

            If Dir(path, FileAttribute.Directory) = "" Then '如果路径不存在,则创建路径
                MkDir(path)
            End If
            CogSerializer.SaveObjectToFile(gTBCheck(0), path & "TBCheck" & (i + 1).ToString & ".vpp")

            MsgBox("保存成功！")
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
        End Try
    End Sub
End Class